// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd.
// SPDX-License-Identifier: MIT

// main.go
package main

import (
	"fmt"
	"os"

	"time_exporter/config"
	"time_exporter/pkg/logger"

	"github.com/sirupsen/logrus"
)

var (
	Name    = "time_exporter"
	Version = "1.0.0"
)

func main() {
	// 初始化日志系统
	logger.InitDefaultLog()

	// 解析命令行参数 (使用kingpin的init函数自动解析)

	logrus.Infof("Starting %s version %s", Name, Version)
	fmt.Printf("%s version %s\n", Name, Version)
	fmt.Println("Time Exporter for Prometheus - UOS Edition")

	if config.ScrapeUrl != nil && *config.ScrapeUrl != "" {
		logrus.Infof("Scrape URL: %s", *config.ScrapeUrl)
	}
	logrus.Infof("Insecure mode: %t", *config.Insecure)

	logrus.Info("Time exporter initialized successfully")

	if err := Run(Name, Version); err != nil {
		logrus.Errorf("Exporter exited with error: %v", err)
		fmt.Fprintf(os.Stderr, "Exporter error: %v\n", err)
		os.Exit(1)
	}
}
